const Api = {
  //API_URL: 'http://47.97.169.9',  //正式环境
  API_URL: 'https://218.13.91.107:4480/', //测试环境
  GetSingle: 'api/XrmData/GetSingle',
  OAUTH_TOKEN:'oauth2/token',
  //添加客诉单
  ADD_RECORD: "interface/api/Marketing/MarketActivitySignin",
  GET_OPTIONS:"api/XrmData/GetEntityOptionSetByName",
  GET_LIST: "api/XrmData/GetMultiple"

}
 const getQueryString = name => {
  var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
  var r = decodeURI(window.location.search).substr(1).match(reg)
  if (r != null) return unescape(r[2])
  return null
}

 //获取姓和名
 const getFirstName= full_name =>{
  var hyphenated = ['欧阳','太史','端木','上官','司马','东方','独孤','南宫','万俟','闻人','夏侯','诸葛','尉迟','公羊','赫连','澹台','皇甫',  
                    '宗政','濮阳','公冶','太叔','申屠','公孙','慕容','仲孙','钟离','长孙','宇文','城池','司徒','鲜于','司空','汝嫣','闾丘','子车','亓官',  
                    '司寇','巫马','公西','颛孙','壤驷','公良','漆雕','乐正','宰父','谷梁','拓跋','夹谷','轩辕','令狐','段干','百里','呼延','东郭','南门',  
                    '羊舌','微生','公户','公玉','公仪','梁丘','公仲','公上','公门','公山','公坚','左丘','公伯','西门','公祖','第五','公乘','贯丘','公皙',  
                    '南荣','东里','东宫','仲长','子书','子桑','即墨','达奚','褚师'];  
  
  var last_name = "";
  var first_name = "";
  //先判断是否全为英文字母 - 若全为英文字母，姓为2个字母。若中英参和或全为中文 - 验证是否存在两名姓， 存在则姓2个字。
  if (full_name.search(/[A-Za-z]/) != -1) {  //中文姓名全为英文
      last_name = full_name.substr(0,2);
      first_name = full_name.substr(2);  
  } else {    //验证是否存在    hyphenated数组中
      if(full_name.length > 2 ){
          var preTwoWords = full_name.substr(0,2);
          if(hyphenated.indexOf(preTwoWords)> -1){  
              last_name = preTwoWords;
              first_name = full_name.substr(2);
          }else{
              last_name = full_name.substr(0,1);
              first_name = full_name.substr(1);
          }
      }else{
          last_name = full_name.substr(0,1);
          first_name = full_name.substr(1);
      }
  }
  return {
      'last_name':last_name,
      'first_name':first_name
  };
}
